#pragma once

template <class THINGY>
struct V2D
{
	static const int X = 0;
	static const int Y = 1;
	static const int NUM_DIMENSIONS = 2;
	THINGY v[2];
	V2D()
	{
		for(int i = 0; i < NUM_DIMENSIONS; ++i)
			v[i] = 0;
	}
	V2D(THINGY x, THINGY y)
	{
		v[X] = x;
		v[Y] = y;
	}
	V2D(const int & number)
	{
		v[X] = number;
		v[Y] = number;
	}
	bool is(THINGY a_x, THINGY a_y)
	{
		return a_x==v[X] && a_y==v[Y];
	}
	bool is(const V2D & a_v)
	{
		for(int i = 0; i < NUM_DIMENSIONS; ++i)
			if(a_v.v[i] != v[i])
				return false;
		return true;
	}
	/**
	 * @return the x coordinate 
	 * @note this function is not allowed to modify it's object
	 */
	const THINGY & getX() const
	{
		return v[X];
	}
	/** this function will not modify it's contents/ */
	const THINGY & getY()const{return v[Y];}
	void addY(THINGY a_value){v[Y]+=a_value;}
	void addX(THINGY a_value){v[X]+=a_value;}
	void setY(THINGY a_value){v[Y]=a_value;}
	void setX(THINGY a_value){v[X]=a_value;}
	void set(THINGY x, THINGY y)
	{
		setX(x);
		setY(y);
	}
	int iterateAround(const V2D & a_max)
	{
		v[X]+=1;
		if(v[X] >= a_max.v[X])
		{
			v[X] = 0;
			v[Y]+=1;
			if(v[Y] > a_max.v[Y])
			{
				return -1;
			}
			return Y;
		}
		return X;
	}
	bool notDoneIterating(V2D & a_bounding)
	{
		return getY() < a_bounding.getY();
	}
};